cmake_minimum_required(VERSION 3.0.0)
project(wl_video VERSION 0.1.0)

enable_language(C)
enable_language(CXX)

set(VERSEON_MAJOR ${wl_video_VERSION_MAJOR})
set(VERSEON_MINOR ${wl_video_VERSION_MINOR})
set(VERSEON_PATCH ${wl_video_VERSION_PATCH})

set(COMMON_FLAGS "-pedantic -Wall -Werror")
set(COMMON_FLAGS
    "${COMMON_FLAGS} -DVERSION_MAJOR=VERSEON_MAJOR")
set(COMMON_FLAGS
    "${COMMON_FLAGS} -DVERSION_MINOR=${VERSEON_MINOR}")
set(COMMON_FLAGS
    "${COMMON_FLAGS} -DVERSION_PATCH=${VERSEON_PATCH}")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")

if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  message(STATUS "Debug mode on")
  set(COMMON_FLAGS "${COMMON_FLAGS} -DZL_DEBUG")
else()
  message(STATUS "Debug mode off")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")

option(BUILD_TEST "Build test programes" OFF)
option(BUILD_EXAMPLES "Build example programs" OFF)

add_subdirectory(src)

if (BUILD_TEST)
include(CTest)
enable_testing()
add_subdirectory(tests)
endif()

if (BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION})
set(CPACK_STRIP_FILES true)
set(CPACK_GENERATOR "TGZ;ZIP")
set(CPACK_PACKAGE_CHECKSUM "MD5")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
    "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Source")
set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
set(CPACK_SOURCE_IGNORE_FILES
    ".clang*;.git;.vscode;build.*;compile_commands.json")
include(CPack)

